﻿Imports System.Text.RegularExpressions

Public Class RequestUtil
    Public Shared Function GetCommand(ByVal Request As String) As String
        Dim RtnVal = Request.ToUpper
        Dim CmdPattern As String = "\/MOBIMIN\-AJAX\/(.*?)\?"
        Return Regex.Matches(RtnVal, CmdPattern, RegexOptions.IgnoreCase).Item(0).Groups(1).Value
    End Function

    Public Shared Function GetQuery(Of T)(ByVal Request As String, ByVal Query As String) As T
        Try
            Request = Request & "&"
            Request = Request.URLDecode
            Dim QueryPattern As String = String.Format("\&{0}\=(.*?)\&", Query)
            Return CType(CObj(Regex.Matches(Request, QueryPattern, RegexOptions.IgnoreCase).Item(0).Groups(1).Value), T)
        Catch ex As Exception
            Return CType(CObj(""), T)
        End Try
    End Function

End Class
